package com.bugu.dao.customer;

import org.springframework.stereotype.Repository;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.bugu.entity.customer.Customer;
/**
 * 客户实体dao，核心之一
 * @author bugu
 *
 */
@Repository
public class CustomerDao extends HibernateDao<Customer, Long> {
	final String QUERY_CUSTOMER_BY_COMPANY_AND_USER
		= "select customer from Customer as customer where customer.company.id = ? and customer.user.loginName = ?";
	final String QUERY_CUSTOMER_BY_USER
		= "select customer from Customer as customer where customer.user.loginName = ?";
	public Page<Customer> findCustomerByCompanyAndUser(Page<Customer> page,Long companyId,String loginName){
		page = find(page,QUERY_CUSTOMER_BY_COMPANY_AND_USER,companyId,loginName);
		return page;
	}
	public Page<Customer> findCustomerByCompany(Page<Customer> page,String loginName){
		page = find(page,QUERY_CUSTOMER_BY_USER,loginName);
		return page;
	}
}
